<template>
  <div>
<!--    <div class="table-operator" v-if="stage !== '05010' && stage !== '05050' && stage !== '01010' && stage !== '01020' && stage !== '01030'">
      <a-button :disabled="status == '9' || status == '2'" v-permission="['10010']" type="primary" @click="showConfirm">
        提交审核
      </a-button>
      <a-button :disabled="status !== '2'" v-permission="['10020']" @click="setApproveReason('9')"> 同意 </a-button>
      <a-button :disabled="status !== '2'" v-permission="['10020']" type="danger" @click="setApproveReason('1')">
        拒绝
      </a-button>
      <a-button @click="showShjl" style="margin-top: 10px">审核记录</a-button>
    </div>-->
    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      class="table_header_blue"
      @change="handleTableChange"
    >
      <span slot="actionName">
        <a-button
          v-if="stage !== '05010' && stage !== '05050'"
          v-permission="['10010']"
          size="small"
          @click="handleAdd('添加人员')"
          type="primary"
          icon="plus"
          >添加人员</a-button
        >
        <span v-else>操作</span>
      </span>
      <span slot="action" slot-scope="text, record" v-if="stage !== '05010' && stage !== '05050'">
        <a @click="handleEdit(record, '人员编辑')">编辑</a>
        <a-divider type="vertical" />
        <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record)">
          <a>删除</a>
        </a-popconfirm>
      </span>
      <span slot="action" slot-scope="text, record" v-else>
        <a-button type="link" @click="handleCheck(record, '查看')">查看</a-button>
      </span>
    </a-table>
    <CheckAndEditModel ref="modalForm" :id="id" @ok="modalFormOk"></CheckAndEditModel>
    <SelectApprove ref="approver" :id="id" @submitData="handleSubmit"></SelectApprove>
    <SetReason ref="setReason" @approveReason="approveData"></SetReason>
    <shjlModal ref="shjlModal" :id="id" :typeId="typeId" :apiUrl="url.applyLog"></shjlModal>
  </div>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { butStatus } from '../public/butStatus'
import CheckAndEditModel from './CheckAndEditModel'
import columns from './indexColumns'
import SelectApprove from '../public/SelectApprover'
import SetReason from '../public/SetReason'
import shjlModal from '../shjlModal'
import { deleteAction, getAction, downFile, getFileAccessHttpUrl, httpAction } from '@/api/manage'
export default {
  props: ['id', 'type', 'stage'],
  name: 'cyxx',
  components: {
    CheckAndEditModel,
    SetReason,
    SelectApprove,
    shjlModal,
  },
  mixins: [JeecgListMixin, butStatus],
  data() {
    return {
      queryParam: {
        proId: this.id,
        stage: this.stage,
        typeId: this.type,
      },
      typeId: this.type,
      columns: columns(this),
      url: {
        list: '/sjxmzygl/sjWorkUsers/queryMemberUserListInfo',
        submit: '/sjxmzygl/sjWorkUsers/submitAudit',
        approve: '/sjxmzygl/sjWorkUsers/zyApplyCommit',
        delete: '/sjxmzygl/sjWorkUsers/delete',
        applyLog: '/sjxmzygl/sjWorkApplyLog/queryApplyLog',
      },
    }
  },
  created() {},
  methods: {
    modalFormOk() {
      this.loadData()
    },
    handleDelete: function (record) {
      if (!this.url.delete) {
        this.$message.error('请设置url.delete属性!')
        return
      }
      var that = this
      let { id, proId, userId } = record
      httpAction(that.url.delete, { id, proId, userId }, 'put').then((res) => {
        if (res.success) {
          // 重新计算分页问题
          that.reCalculatePage(1)
          that.$message.success(res.message)
          that.loadData()
        } else {
          that.$message.warning(res.message)
        }
      })
    },
  },
}
</script>

<style lang="less" scoped>
@import '~@assets/less/tableTheme.less';
</style>